<template>
   <div >
      <slot name="show">
        <div class="empty">
            <img src="../assets/g1.gif" alt="">    
            <p>您的购物车容量为5吨</p>
            <span @click="rightnow">立刻购买 ></span>
        </div>  
         <div class="footer">
            <h2>· 为您推荐 ·</h2>
             <ul class="more-goods-con">
            <li v-for="(item,i) in list" :key="i" @click="detail(item.pid)">
               <div class="more-good-wrap">
                  <img :src="item.pimg" alt="">
               </div>
               <h3>{{item.pname}}</h3>
               <p>￥{{item.pprice}}</p>
            </li>
             
         </ul>
        </div>
          
    </slot>    
   </div>  
</template>

<script>
import * as api from '../../api/getproductlist'
export default {
    name:'Show',
    data(){
        return {
            list:[]
        }
    },
    methods:{
       
       detail(id){
      this.$router.push("/detailpro/" + id);           
        },
        rightnow(){
           this.$router.push('/p1')
        },
        
    },
   mounted(){
      api.getclasspro({classid:1}).then(data=>{
         this.list=data.data.data;
         //  this.flag='show'  
      })
      
   }
}
</script>

<style scoped>
.empty{
    display: flex;
    flex-direction: column;
    align-items: center
}
.empty img{
    width: 250px
}
.empty  p{
    height: 30px;
    line-height: 30px;
    font-size: 14px
}
.empty span{
    font-size: 14px;
    color:#d82020 
}
.footer h2{
    height: 50px;
    line-height: 50px;
    color: red;
    font-size: 14px;
    text-align: center;
    font-weight: normal;
    background: #fff;
    margin-bottom: 0
}
.more-goods-con .more-good-wrap{
   width: 100%;
   height: 130px;
   margin-top: 15px;
   margin-bottom: 15px
}
.more-goods-con .more-good-wrap img{
   display: inline-block;
     width: 100%;
   height: 100%;
   background: red
}
.more-goods-con {
   width: 100%;
   display: flex;
   flex-wrap: wrap;
   justify-content: space-between;
   background: #fff;
   min-height: 300px
}
.more-goods-con li h3,p{
   margin: 0
}
.more-goods-con li p{
   width: 100%;
   text-align: left;
   color: red;
   font-size: 12px;
   height: 30px;
}
.more-goods-con li h3{
     width:100%;
    word-break:break-all;
    text-overflow:ellipsis;
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    overflow:hidden;
    font-weight: normal;
    color: #323232;
    margin-bottom: 10px
}
.more-goods-con li{
   width: 50%;
   border: 1px solid #f3f3f3;
   height: 230px;
   padding: 10px 6px;
   box-sizing: border-box;
   border-right:0;
   margin-top:-1px ;
   display: flex;
   flex-direction: column;
   align-items: center;
  justify-content:start;
  padding-bottom: 0
}
.more-goods-con li:nth-child(odd){
   border-left:0 
}
</style>